package cn.iocoder.yudao.module.mqtt.dal.mysql.mqtt;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.mqtt.controller.admin.config.vo.ConfigPageReqVO;
import cn.iocoder.yudao.module.mqtt.dal.dataobject.config.MqttConfig2DO;
import cn.iocoder.yudao.module.mqtt.dal.dataobject.mqtt.MqttConfigDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * MQTT配置 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface MqttConfigMapper extends BaseMapperX<MqttConfigDO> {
    default PageResult<MqttConfigDO> selectPage(ConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MqttConfigDO>()
                .likeIfPresent(MqttConfigDO::getName, reqVO.getName())
                .likeIfPresent(MqttConfigDO::getUsername, reqVO.getUsername())
                .eqIfPresent(MqttConfigDO::getPassword, reqVO.getPassword())
                .eqIfPresent(MqttConfigDO::getUrl, reqVO.getUrl())
                .eqIfPresent(MqttConfigDO::getSubClientId, reqVO.getSubClientId())
                .eqIfPresent(MqttConfigDO::getSubTopics, reqVO.getSubTopics())
                .eqIfPresent(MqttConfigDO::getPubClientId, reqVO.getPubClientId())
                .eqIfPresent(MqttConfigDO::getEnabled, reqVO.getEnabled())
                .eqIfPresent(MqttConfigDO::getDescription, reqVO.getDescription())
//                .betweenIfPresent(MqttConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MqttConfigDO::getId));
    }
} 